#include "UController.h"

UController::UController()
{
}

bool   UController::printerON()
{
   int fd = initSerialPort(O_RDWR | O_NOCTTY | O_NDELAY);
   if (fd < 1) return false;

   if (deviceSitch(fd, "PN") > 0) {
      closeSerialport(fd);
      return true;
   }

   closeSerialport(fd);
   return false;
}

bool   UController::openEthernetgate()
{
   int fd = initSerialPort(O_RDWR | O_NOCTTY | O_NDELAY);
   if (fd < 1) return false;
   if (openGate(fd, 0x1) > 0) {
      char twobytes[2] = {0x0}, mask = 0x20;
      if (runCommand(fd, "ES", twobytes) > 0) {
         if ((twobytes[0] & mask) == mask) {
            closeSerialport(fd);
            return true;
         }
      }
   }
   closeSerialport(fd);
   return false;
}
